{% extends 'TopxiaWebBundle::layout.html.twig' %}

{% block title %}{{ course.title }} - {{ parent() }}{% endblock %}

{%- block keywords -%}
  {% if category %}{{ category.name }}{% endif %}
  {% for tag in tags %}{{ tag.name }}{% endfor %}
  {{ course.title }} {{ setting('site.name') }}
{%- endblock -%}
{% block description %}{{ course.about|plain_text(150) }}{% endblock %}


{% set script_controller = 'course/show' %}

{% block content %}

{% if member and member.locked %}
<div class="row">
  <div class="col-md-12">
    <div class="mtl alert alert-warning">
      您的退款申请已提交，请等待管理员的处理，退款期间将不能学习课程。
      <button class="btn btn-warning btn-sm cancel-refund" data-url="{{ path('course_order_cancel_refund', {id:course.id}) }}">取消退款，继续学习！</button>
    </div>
  </div>
</div>
{% endif %}

{% if course.type == 'live' %}

  {% include 'TopxiaWebBundle:Course:live-course.html.twig' %}

{% else %}
<div class="es-row-wrap container-gap course-cover">

	<div class="row row-5-7 course-cover-heading">
		<div class="col-sm-5 picture hidden-xs">
			{% if setting('course.picturePreview_enabled')|default(0) > 0  and freeLesson %}
			<a  href="#modal" data-toggle="modal" data-url="{{ path('course_lesson_preview', {courseId:freeLesson.courseId, lessonId:freeLesson.id}) }}" ><img src="{{ default_path('coursePicture', course.largePicture, '') }}" class="img-responsive" /></a>
			{% else %}
			<img src="{{ default_path('coursePicture', course.largePicture, '') }}" class="img-responsive" />
			{% endif %}
		</div>
		<div class="col-sm-7 info">
			{% if is_granted('ROLE_ADMIN') %}
			<div class="btn-group pull-right">
				<button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> <i class="glyphicon glyphicon-cog"></i>
				</button>
				<ul class="dropdown-menu pull-right">
					<li>
						<a href="{{ path('course_manage', {id:course.id}) }}">课程管理</a>
					</li>
				</ul>
			</div>
			{% endif %}
			<h1 class="title">{{ course.title }}</h1>
			<div class="subtitle">{{ course.subtitle }}</div>
			<div class="stats">
				<p>
					价　格：
					{% if course.price > 0 %}
						{% if free_limit_type(course) == 'free_now' %}
							<span class="money-num">0.00</span>
							<span class="money-text">元</span>
							<span class="text-muted">(原价：<del>{{ course.price }}</del> 元)</span>
							<span class="mll">{% include 'TopxiaWebBundle:Course:countdown.html.twig' with {'course':course} %}</span>
						{% else %}
							<span class="money-num">{{ course.price }}</span>
							<span class="money-text">元</span>
							&nbsp;&nbsp;&nbsp;
						 {% if setting('coin.coin_enabled') %}
						 {% if course.coinPrice > 0 %}
						 <span class="coin-price" >
							<span >{{ course.coinPrice }}</span>
							<span  > {{setting('coin.coin_name')}}</span>
						</span>
						{% endif %}  
						{% endif %}  

						{% endif %}  
					{% else %}
						<span class="money-num" style="font-size:16px;">免费</span>
					{% endif %}
				</p>
								
				<p>
					评　价：
					<span class="stars-{{ (course.rating)|number_format }}">&nbsp;</span>
					<span class="rating-num">{{ course.rating|number_format(1) }}分</span>
					<a class="rating-user-num show-course-review-pane" href="javascript:">({{ course.ratingNum }}人评价)</a>
				</p>
				{% if course.showStudentNumType == 'opened' %}
				<p>
					学员数：
					<span class="member-num">{{ course.studentNum }}</span>
					<span class="member-text">人</span>
				</p>
				{% endif %}
				{% if not course.expiryDay == 0 %}
				<p>
					有效期：
					<span class="member-num">{{ course.expiryDay }}</span>
					<span class="member-text">天</span>
				</p>
				{% endif %}
				<p>
					{% if course.status=='closed' %}  
						状　态： <span class="label label-danger ">已关闭</span>
					{% elseif course.status=='draft' %}
						状　态： <span class="label label-warning ">未发布</span>
					{% endif %}          
				</p>
			</div>
			<div class="actions clearfix">
				<div class="pull-left">
					{% if course.status != 'published' %}
					{% else %}
						<a class="btn btn-primary btn-fat" id="course-buy-btn" href="#modal" data-toggle="modal" data-url="{{ path('course_buy', {id:course.id}) }}">{% if course.price > 0 and (date(course.freeStartTime) >= date() or date(course.freeEndTime) < date()) %}购买课程{% else %}加入学习{% endif %}</a>

						{% if courseMemberLevel %}
							{% if checkMemberLevelResult == 'not_login' %}
								<a href="{{ path('login') }}" class="btn btn-warning mll">{{ courseMemberLevel.name }}，免费学</a>  
							{% elseif checkMemberLevelResult in ['not_member', 'member_expired'] %}
								<a href="{{ path('vip_buy') }}" class="btn btn-warning mll">{{ courseMemberLevel.name }}，免费学</a>  
							{% elseif checkMemberLevelResult == 'level_low' %}
								<a href="{{ path('vip_upgrade', {level:courseMemberLevel.id}) }}" class="btn btn-warning mll">{{ courseMemberLevel.name }}，免费学</a>
							{% elseif checkMemberLevelResult == 'ok' %}
								<a href="javascript:;" data-url="{{ path('course_become_use_member', {id:course.id}) }}" class="btn btn-warning mll become-use-member-btn">{{ courseMemberLevel.name }}，免费学</a>
							{% endif %}

						{% endif %}
					{% endif %}
				</div>
				
				<div class="pull-right ">

					<a class="btn btn-link" href="#" style="display:none;"> <i class="glyphicon glyphicon-play-circle"></i>
						免费体验
					</a>
					<a class="btn btn-link " id="favorite-btn" href="javascript:" data-url="{{ path('course_favorite', {id:course.id}) }}" {% if hasFavorited %}style="display:none;"{% endif %}>
						<i class="glyphicon glyphicon-bookmark"></i>
						收藏课程
					</a>
					<a class="btn btn-link" id="unfavorite-btn" href="javascript:" data-url="{{ path('course_unfavorite', {id:course.id}) }}" {% if not hasFavorited %}style="display:none;"{% endif %}>
						<i class="glyphicon glyphicon-bookmark"></i>
						已收藏
					</a>
					<a class="btn btn-link" href="#" style="display:none;">
						<i class="glyphicon glyphicon-gift"></i>
						赠送
					</a>

				</div><div class="share pull-right clearfix"  data-bdText="{{courseShareContent}}"></div>
			</div>

		</div>
	</div>

	<div class="row row-8-4">
		<div class="col-md-8">

			<div class="course-nav-tabs">
				<ul class="nav mbl nav-pills" id="course-nav-tabs">
					<li class="active">
						<a href="#course-about-pane" class="btn-index" data-anchor="#course-about-pane">课程介绍</a>
					</li>
					{% if course.goals %}
						<li>
							<a href="#course-goal-pane" class="btn-index" data-anchor="#course-goal-pane">课程目标</a>
						</li>
					{% endif %}
					{% if course.audiences %}
						<li>
							<a href="#course-audience-pane" class="btn-index" data-anchor="#course-audience-pane">适合人群</a>
						</li>
					{% endif %}
					<li>
						<a href="#course-list-pane" class="btn-index" data-anchor="#course-list-pane">课程列表</a>
					</li>
					<li>
						<a href="#course-review-pane" class="btn-index" data-anchor="#course-review-pane">
							课程评价
							<span class="badge">{{ course.ratingNum }}</span>
						</a>
					</li>
					<li class="pull-right" style="display:none;" >
					<div>
						<a class="btn btn-primary nav-course-buy-btn" id="course-buy-btn" href="#modal" data-toggle="modal" data-url="{{ path('course_buy', {id:course.id}) }}" >{% if course.price > 0 and (date(course.freeStartTime) >= date() or date(course.freeEndTime) < date()) %}购买课程{% else %}加入学习{% endif %}</a>
					</div>
					</li>
				</ul>
			</div>


			{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {'id' : 'course-about-pane'} %}
				{% block heading %}
					<h3 class="panel-title">课程介绍</h3>
				{% endblock %}
				{% block body %}

					{% if course.about %}
						{{ course.about|raw }}
					{% else %}
						<span class="text-muted">还没有课程介绍...</span>
					{% endif %}
					{% if tags %}
						<div class="mtm">
						<span class="text-muted">标签：</span>{% for tag in tags %}
						<a href="{{ path('tag_show', {name:tag.name}) }}" class="mrs">{{ tag.name }}</a>
						{% endfor %}
						</div>
					{% endif %}

				{% endblock %}
			{% endembed %}

			{% if course.goals %}
				{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {'id' : 'course-goal-pane'} %}
					{% block heading %}
						<h3 class="panel-title">课程目标</h3>
					{% endblock %}
					{% block body %}
						<ul class="media-list">
							{% for goal in course.goals  %}
							<li class="media">
								<div class="pull-left">
									<span class="glyphicon glyphicon-flag media-object"></span>
								</div>
								<div class="media-body">{{ goal }}</div>
							</li>
							{% endfor %}
						</ul>
					{% endblock %}
				{% endembed %}
			{% endif %}

			{% if course.audiences %}
				{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {'id' : 'course-audience-pane'} %}
					{% block heading %}
						<h3 class="panel-title">适合人群</h3>
					{% endblock %}
					{% block body %}
						<ul class="media-list">
							{% for audience in course.audiences %}
							<li class="media">
								<div class="pull-left">
									<span class="glyphicon glyphicon-user media-object"></span>
								</div>
								<div class="media-body">{{ audience }}</div>
							</li>
							{% endfor %}
						</ul>
					{% endblock %}
				{% endembed %}
			{% endif %}

			{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {'id' : 'course-list-pane'} %}
				{% block heading %}
					<h3 class="panel-title">课时列表</h3>
				{% endblock %}
				{% block body %}

					{% include 'TopxiaWebBundle:CourseLesson:item-list-multi.html.twig' with {experience: true} %}

				{% endblock %}
			{% endembed %}


			{% if courseReviews %}
			{% embed "TopxiaWebBundle:Bootstrap:panel.html.twig" with {'id' : 'course-review-pane'} %}
				{% block heading %}
					<h3 class="panel-title">课程评价</h3>
				{% endblock %}
				{% block body %}

					<div id="course-review-pane-show" data-url="{{ path('course_review_list', {id:course.id, previewAs:previewAs}) }}">正在载入课程评价数据...</div>

				{% endblock %}
			{% endembed %}
			{% endif %}

			{% if setting('course.relatedCourses') == 1 %}
				{{ render(controller('TopxiaWebBundle:Course:relatedCoursesBlock',{course:course})) }}
			{% endif %}
		</div>
		<div class="col-md-4">
			{{ render(controller('TopxiaWebBundle:Course:teachersBlock',{course:course})) }}

			{{ render(controller('TopxiaWebBundle:CourseThread:latestBlock',{course:course})) }}

			{{ render(controller('TopxiaWebBundle:Course:latestMembersBlock',{course:course})) }}

			{{ render(controller('TopxiaWebBundle:CourseAnnouncement:block',{course:course})) }}

		</div>
	</div>

</div>
{% endif %}
</div>

{% endblock %}

{% block bottom %}
<div id="course-modal" class="modal"></div>
<div id="course-edit-modal" class="modal"></div>
{% endblock %}

